let logger = require('morgan');
let fileStreamRotator = require('file-stream-rotator')
const fs = require("fs");
const path = require("path");

let logDir = path.join(__dirname, '../', '../', '/logs')

//若检测不到对应文件夹 就创建文件夹
fs.existsSync(logDir) || fs.mkdirSync(logDir)

let accessLogStream = fileStreamRotator.getStream({
    date_format: 'YYYY-MM-DD', filename: path.join(logDir, 'access-%DATE%.log'), frequency: 'daily', verbose: false
})


module.exports = exports = log = (format = 'combined') => logger(format, {stream: accessLogStream})
